<?php
/* @var $this SiteController */

$this->pageTitle = Yii::app()->name;
?>

<!-- Example row of columns -->
<div class="row">
    <div class="col-lg-3">
        <ul class="nav nav-pills nav-stacked" style="background-color:#eeeeee">
            <!-- <li class="nav-header disabled">OTC Ideality</li>-->
            <?php
            foreach ($listCategory as $index => $row) {
                if ($row['id'] == $cate_id) {
                    echo '<li class="active">' . CHtml::link($row["title"], array("/site/listideality", "cate_id" => $row["id"])) . '</li>';
                } else {
                    echo '<li>' . CHtml::link($row["title"], array("/site/listideality", "cate_id" => $row["id"])) . '</li>';
                }
            }
            ?>
        </ul>
    </div>
    <div class="col-lg-9">
        <?php

        if (count($data) > 0) {

            ?>
            <table class="table  table-bordered">
                <tr>
                    <th width="5%">No</th>
                    <?php if (!Yii::app()->user->isGuest) {

                        ?>
                        <th>Author</th>
                    <?php } ?>
                    <th width="30%">Title</th>
                    <th width="30%">Description</th>
                    <?php if (!Yii::app()->user->isGuest) {

                        ?>
                        <th>Partial Price</th>
                        <th>Full Price</th>
                    <?php } ?>
                </tr>
                <?php
                $index = 1;

                foreach ($data as $row) {
                    ?>
                    <tr>
                        <td><?php echo $index++; ?></td>
                      <?php if (!Yii::app()->user->isGuest) {
                                echo '<td>'. $row['user']['profile']['firstname'] . ' ' . $row['user']['profile']['lastname'].'</td>';
                            } ?>
                        <td><?php if ($role != 'ADMIN' && $role != 'PREMIUM') {
                                echo Param::limitWord($row['title'], 10);
                            } else {
                                echo $row['title'];
                            } ?></td>
                        <td><?php if ($role != 'ADMIN' && $role != 'PREMIUM') {
                                echo Param::limitWord($row['short_description'], 20);
                            } else {
                                echo $row['short_description'];
                            } ?></td>
                        <?php if (!Yii::app()->user->isGuest) { ?>
                            <td>
                                <?php echo $row['partly_price'] == 0 ? '' : $row['partly_price']; ?>
                                <?php
                                if ($row['partly_price'] > 0) {
                                    echo CHtml::submitButton('Buy now', array('submit' => array('/site/confirmOrder', 'ideality_id' => $row['id'], 'trans_type' => Param::TRANS_TYPE_PARTIAL_PRICE), 'class' => 'btn btn-success'));
                                }
                                ?>
                            </td>
                            <td><?php echo $row['full_price'] == 0 ? '' : $row['full_price']; ?>
                                <?php
                                if ($row['full_price'] > 0) {
                                    echo CHtml::submitButton('Buy now', array('submit' => array('/site/confirmOrder', 'ideality_id' => $row['id'], 'trans_type' => Param::TRANS_TYPE_FULL_PRICE), 'class' => 'btn btn-success'));
                                }
                                ?>
                            </td>
                        <?php } ?>
                    </tr>

                <?php
                }
                ?>
            </table>
            <?php
            if (!Yii::app()->user->isGuest) {
                ?>
                <p class="note"><b>Note: </b></p>
                <p class="note"><b>Partial price</b>: Project's materials and information will be kept visible on
                    website
                    after partial price payment is made. Each project can have multiple partial price transactions.</p>
                <p class="note"><b>Full price</b>: Project's materials and information will be removed from website
                    after
                    full price payment is made. Each project can only have 1 full price transaction.</p>
            <?php } ?>
        <?php
        }
        if (count($data) == 0) {
            echo 'No data available for this category';
        }
        ?>


    </div>

</div>

